import React, { useState,useMemo, useCallback } from 'react'
import B from './B'
import C from './C'

export default function A() {
    // 声明数量状态
    const [count,setCount] = useState(0)
    // 修改数量的方法
    // const handleClick = () => setCount(pre => pre+1)
    // const aaa= useMemo(()=> {
    //     return handleClick
    // },[])
    // const aaa = useMemo(() => () => setCount((pre) => pre+1),[])//简写写法
    const aaa = useCallback(() => setCount((pre) => pre+1),[])
    console.log('A组件更新了');

  return (
    <div>
        <h1>我被点击了{count}次</h1>
        <B fn={aaa} />
        <C />
    </div>
  )
}
